package com.stox.client.ui.javafx.chartingy.widget;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.layout.Region;

import com.stox.client.ui.javafx.chartingy.model.chart.Chart;
import com.stox.client.ui.javafx.core.util.CSS;
import com.stox.client.ui.javafx.core.util.UI;

public class MouseZoomIndicator extends Region {

	private final Chart<?, ?> chart;

	public MouseZoomIndicator(final Chart<?, ?> chart) {
		UI.style(this, CSS.mouseZoomIndicator);
		this.chart = chart;
		layoutYProperty().bind(chart.getChartContentArea().layoutYProperty());
		chart.getChartContentArea().heightProperty().addListener(new ChangeListener<Number>() {
			@Override
			public void changed(final ObservableValue<? extends Number> observable, final Number oldValue, final Number newValue) {
				setHeight(newValue.doubleValue());
			}
		});
		setHeight(chart.getChartContentArea().getHeight());
	}

	public Chart<?, ?> getChart() {
		return chart;
	}

	@Override
	public void setWidth(final double value) {
		super.setWidth(value);
	}

}
